package org.spcloud.service.msg;

import java.util.Date;

import org.spcloud.service.msg.config.message.MessageBinding;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.Message;

@EnableBinding(MessageBinding.class)
@EnableEurekaClient
@SpringBootApplication
public class MsgApplication {

	public static void main(String[] args) {

		SpringApplication.run(MsgApplication.class, args);
		
	}

	/**
	 * 监听消息接收
	 * 
	 * @param message
	 */
	@StreamListener(value="smsSenderOrder")
	public void getMessage(Message<String> message) {
		System.out.println(message.getHeaders().entrySet());
		System.out.println(message.getHeaders().getId());
		System.out.println(message.getHeaders().getTimestamp());
		System.out.println("接收到的消息:" + message.getPayload());
	}
	
	@StreamListener("smsSenderUser")
	public void getUserMessage(Message<String> message) {
		System.out.println("接收到的消息:" + message.getPayload());
	}
}
